package com.nsl.my_youlai.Jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;

public class LeaderSerializer extends StdSerializer<Leader> {
    public LeaderSerializer() {
        this(null);
    }

    protected LeaderSerializer(Class<Leader> t) {
        super(t);
    }

    @Override
    public void serialize(Leader value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        if (value == null) {
            gen.writeNull();
            return;
        }
        // 直接输入领导人姓名，不需要起始和结束的花括号
        gen.writeString(value.getLeaderName());
    }
}
